package acwing;

import java.io.*;

public class A4 {
    static int n;
    static int m;
    static int N=110;
    static int[] v=new int[N];
    static int[] w=new int[N];
    static int[] s=new int[N];
    static int[][] dp=new int[N][N];
    static BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter log=new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] t = read.readLine().split(" ");
n=Integer.parseInt(t[0]);
m=Integer.parseInt(t[1]);
for(int i=1;i<=n;i++){
    String[] s1 = read.readLine().split(" ");
    int a=Integer.parseInt(s1[0]);
    int b=Integer.parseInt(s1[1]);
    int c=Integer.parseInt(s1[2]);
    v[i]=a;
    w[i]=b;
    s[i]=c;
}
for(int i=1;i<=n;i++){//枚举第i个物品的决策
    for(int j=0;j<=m;j++){
        for(int k=0;k<=s[i];k++){
            if(k*v[i]<=j)
                dp[i][j]=Math.max(dp[i][j],dp[i-1][j-k*v[i]]+k*w[i]);
        }
    }
}
        log.write(Integer.toString(dp[n][m]));
log.flush();
    }
}
